<template>
  <footer class="footer">
    <span class="todo-count">剩余<strong>数量值</strong>{{ leftCount }}</span>
    <ul class="filters">
      <li>
        <a
          :class="{ selected: type === 'All' }"
          href="javascript:;"
          @click="change('All')"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: type === 'active' }"
          href="javascript:;"
          @click="change('active')"
          >未完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: type === 'complete' }"
          href="javascript:;"
          @click="change('complete')"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="clean" v-show="isShow">
      清除已完成
    </button>
  </footer>
</template>

<script>
export default {
  data() {
    return {
      type: "All",
    };
  },
  props: ["arr"],
  computed: {
    leftCount() {
      return this.arr.filter((item) => !item.isDone).length;
    },
    isShow() {
      return this.arr.some((item) => item.isDone);
    },
  },
  methods: {
    change(val) {
      this.type = val;
      this.$emit("change", val);
    },
    clean() {
      this.$emit("clean");
    },
  },
};
</script>
